View Javadoc

1   /*
2    * The Apache Software License, Version 1.1
3    *
4    *
5    * Copyright (c) 2001-2004 The Apache Software Foundation.  All rights
6    * reserved.
7    *
8    * Redistribution and use in source and binary forms, with or without
9    * modification, are permitted provided that the following conditions
10   * are met:
11   *
12   * 1. Redistributions of source code must retain the above copyright
13   *    notice, this list of conditions and the following disclaimer.
14   *
15   * 2. Redistributions in binary form must reproduce the above copyright
16   *    notice, this list of conditions and the following disclaimer in
17   *    the documentation and/or other materials provided with the
18   *    distribution.
19   *
20   * 3. The end-user documentation included with the redistribution,
21   *    if any, must include the following acknowledgment:
22   *       "This product includes software developed by the
23   *        Apache Software Foundation (http://www.apache.org/)."
24   *    Alternately, this acknowledgment may appear in the software itself,
25   *    if and wherever such third-party acknowledgments normally appear.
26   *
27   * 4. The names "Axis" and "Apache Software Foundation" must
28   *    not be used to endorse or promote products derived from this
29   *    software without prior written permission. For written
30   *    permission, please contact apache@apache.org.
31   *
32   * 5. Products derived from this software may not be called "Apache",
33   *    nor may "Apache" appear in their name, without prior written
34   *    permission of the Apache Software Foundation.
35   *
36   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47   * SUCH DAMAGE.
48   * ====================================================================
49   *
50   * This software consists of voluntary contributions made by many
51   * individuals on behalf of the Apache Software Foundation.  For more
52   * information on the Apache Software Foundation, please see
53   * <http://www.apache.org/>.
54   */
55  
56  package org.apache.geronimo.ews.ws4j2ee.context.wsdl.impl;
57  
58  import org.apache.axis.wsdl.symbolTable.BindingEntry;
59  import org.apache.axis.wsdl.symbolTable.Element;
60  import org.apache.axis.wsdl.symbolTable.PortEntry;
61  import org.apache.axis.wsdl.symbolTable.PortTypeEntry;
62  import org.apache.axis.wsdl.symbolTable.ServiceEntry;
63  import org.apache.axis.wsdl.symbolTable.TypeEntry;
64  import org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext;
65  import org.apache.geronimo.ews.ws4j2ee.context.wsdl.type.SchemaType;
66  
67  import javax.wsdl.Definition;
68  import javax.wsdl.Service;
69  import javax.xml.namespace.QName;
70  import java.util.Collection;
71  import java.util.HashMap;
72  import java.util.Map;
73  
74  /***
75   * <p>This Class is a wrapper fo the Axis SymbolTable. Since SymbolTable is parsed
76   * completly it is not editable so the methods will throw the
77   * UnsupportedOperationException.</p>
78   *
79   * @author Srinath Perera(hemapani@opensource.lk)
80   * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext
81   */
82  public class AxisEmitterBasedWSDLContext extends AbstractWSDLContext implements WSDLContext {
83      private Definition definition;
84      private HashMap services;
85      private HashMap bindings;
86      private HashMap portetypes;
87      private HashMap ports;
88  
89      public AxisEmitterBasedWSDLContext(Definition definition) {
90          this.definition = definition;
91      }
92  
93      /***
94       * Symbol table can't be edited
95       */
96      public void addService(Service service) {
97          throw new UnsupportedOperationException("Symboltable can't be edited");
98      }
99  
100     /***
101      * Symbol table can't be edited
102      */
103     public void addType(SchemaType type) {
104         throw new UnsupportedOperationException("Symboltable can't be edited");
105     }
106 
107     /***
108      * 
109      */
110     public BindingEntry getBinding(QName bindingname) {
111         return new BindingEntry(definition.getBinding(bindingname));
112     }
113 
114     /* (non-Javadoc)
115      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getBindings()
116      */
117     public Collection getBindings() {
118         return definition.getBindings().values();
119     }
120 
121     /* (non-Javadoc)
122      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getPortType(org.apache.xml.utils.QName)
123      */
124     public PortTypeEntry getPortType(QName portname) {
125         return new PortTypeEntry(definition.getPortType(portname));
126     }
127 
128     /* (non-Javadoc)
129      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getPortTypes()
130      */
131     public Collection getPortTypes() {
132         return definition.getBindings().values();
133     }
134 
135     /* (non-Javadoc)
136      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getService(org.apache.xml.utils.QName)
137      */
138     public ServiceEntry getService(QName servicename) {
139         return new ServiceEntry(definition.getService(servicename));
140     }
141 
142     /* (non-Javadoc)
143      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getServices()
144      */
145     public Collection getServices() {
146         return definition.getServices().values();
147     }
148 
149     /* (non-Javadoc)
150      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getType(org.apache.xml.utils.QName)
151      */
152     public TypeEntry getType(QName typename) {
153         throw new UnsupportedOperationException("Symboltable can't be edited");
154     }
155 
156     /* (non-Javadoc)
157      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getTypes()
158      */
159     public Map getTypes() {
160         throw new UnsupportedOperationException("Symboltable can't be edited");
161     }
162 
163     /* (non-Javadoc)
164      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getElement(javax.xml.namespace.QName)
165      */
166     public Element getElement(QName name) {
167         throw new UnsupportedOperationException("Symboltable can't be edited");
168     }
169 
170     /* (non-Javadoc)
171      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getPort()
172      */
173     public PortEntry getPort(QName name) {
174         throw new UnsupportedOperationException("Symboltable can't be edited");
175     }
176 
177     /* (non-Javadoc)
178      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getTargetNSURI()
179      */
180     public String getTargetNSURI() {
181         return definition.getTargetNamespace();
182     }
183 }